Change-Id: Ia6e1e819ec6cbe8bf75b820109f51d47863e31fc
20 files changed:
*/
public static function normaliseSpecialPage( LinkTarget $target ) {
if ( $target->getNamespace() == NS_SPECIAL && !$target->isExternal() ) {
*/
public static function normaliseSpecialPage( LinkTarget $target ) {
if ( $target->getNamespace() == NS_SPECIAL && !$target->isExternal() ) {
- list( $name, $subpage ) = SpecialPageFactory::resolveAlias( $target->getDBkey() );
+ list( $name, $subpage ) = MediaWikiServices::getInstance()->getSpecialPageFactory()->
+ resolveAlias( $target->getDBkey() );
if ( !$name ) {
return $target;
}
if ( !$name ) {
return $target;
}
// Redirect loops, titleless URL, $wgUsePathInfo URLs, and URLs with a variant
} elseif ( !$this->tryNormaliseRedirect( $title ) ) {
// Prevent information leak via Special:MyPage et al (T109724)
// Redirect loops, titleless URL, $wgUsePathInfo URLs, and URLs with a variant
} elseif ( !$this->tryNormaliseRedirect( $title ) ) {
// Prevent information leak via Special:MyPage et al (T109724)
+ $spFactory = MediaWikiServices::getInstance()->getSpecialPageFactory();
if ( $title->isSpecialPage() ) {
if ( $title->isSpecialPage() ) {
- $specialPage = SpecialPageFactory::getPage( $title->getDBkey() );
+ $specialPage = $spFactory->getPage( $title->getDBkey() );
if ( $specialPage instanceof RedirectSpecialPage ) {
$specialPage->setContext( $this->context );
if ( $this->config->get( 'HideIdentifiableRedirects' )
&& $specialPage->personallyIdentifiableTarget()
) {
if ( $specialPage instanceof RedirectSpecialPage ) {
$specialPage->setContext( $this->context );
if ( $this->config->get( 'HideIdentifiableRedirects' )
&& $specialPage->personallyIdentifiableTarget()
) {
- list( , $subpage ) = SpecialPageFactory::resolveAlias( $title->getDBkey() );
+ list( , $subpage ) = $spFactory->resolveAlias( $title->getDBkey() );
$target = $specialPage->getRedirect( $subpage );
// target can also be true. We let that case fall through to normal processing.
if ( $target instanceof Title ) {
$target = $specialPage->getRedirect( $subpage );
// target can also be true. We let that case fall through to normal processing.
if ( $target instanceof Title ) {
// Special pages ($title may have changed since if statement above)
if ( $title->isSpecialPage() ) {
// Actions that need to be made when we have a special pages
// Special pages ($title may have changed since if statement above)
if ( $title->isSpecialPage() ) {
// Actions that need to be made when we have a special pages
- SpecialPageFactory::executePath( $title, $this->context );
+ $spFactory->executePath( $title, $this->context );
} else {
// ...otherwise treat it as an article view. The article
// may still be a wikipage redirect to another article or URL.
} else {
// ...otherwise treat it as an article view. The article
// may still be a wikipage redirect to another article or URL.
}
if ( $title->isSpecialPage() ) {
}
if ( $title->isSpecialPage() ) {
- list( $name, $subpage ) = SpecialPageFactory::resolveAlias( $title->getDBkey() );
+ list( $name, $subpage ) = MediaWikiServices::getInstance()->getSpecialPageFactory()->
+ resolveAlias( $title->getDBkey() );
if ( $name ) {
$title = SpecialPage::getTitleFor( $name, $subpage );
}
if ( $name ) {
$title = SpecialPage::getTitleFor( $name, $subpage );
}
$invokedWithSuccess = true;
if ( $sock ) {
$invokedWithSuccess = true;
if ( $sock ) {
- $special = SpecialPageFactory::getPage( 'RunJobs' );
+ $special = MediaWikiServices::getInstance()->getSpecialPageFactory()->
+ getPage( 'RunJobs' );
$url = $special->getPageTitle()->getCanonicalURL( $query );
$req = (
"POST $url HTTP/1.1\r\n" .
$url = $special->getPageTitle()->getCanonicalURL( $query );
$req = (
"POST $url HTTP/1.1\r\n" .
if ( $ns == NS_SPECIAL ) {
list( $canonicalSpecialPageName, /*...*/ ) =
if ( $ns == NS_SPECIAL ) {
list( $canonicalSpecialPageName, /*...*/ ) =
- SpecialPageFactory::resolveAlias( $title->getDBkey() );
+ MediaWikiServices::getInstance()->getSpecialPageFactory()->
+ resolveAlias( $title->getDBkey() );
} elseif ( $this->canUseWikiPage() ) {
$wikiPage = $this->getWikiPage();
$curRevisionId = $wikiPage->getLatest();
} elseif ( $this->canUseWikiPage() ) {
$wikiPage = $this->getWikiPage();
$curRevisionId = $wikiPage->getLatest();
$subpageSearch = $searchParts[1] ?? null;
// Handle subpage search separately.
$subpageSearch = $searchParts[1] ?? null;
// Handle subpage search separately.
+ $spFactory = MediaWikiServices::getInstance()->getSpecialPageFactory();
if ( $subpageSearch !== null ) {
// Try matching the full search string as a page name
$specialTitle = Title::makeTitleSafe( NS_SPECIAL, $searchKey );
if ( !$specialTitle ) {
return [];
}
if ( $subpageSearch !== null ) {
// Try matching the full search string as a page name
$specialTitle = Title::makeTitleSafe( NS_SPECIAL, $searchKey );
if ( !$specialTitle ) {
return [];
}
- $special = SpecialPageFactory::getPage( $specialTitle->getText() );
+ $special = $spFactory->getPage( $specialTitle->getText() );
if ( $special ) {
$subpages = $special->prefixSearchSubpages( $subpageSearch, $limit, $offset );
return array_map( function ( $sub ) use ( $specialTitle ) {
if ( $special ) {
$subpages = $special->prefixSearchSubpages( $subpageSearch, $limit, $offset );
return array_map( function ( $sub ) use ( $specialTitle ) {
// Unlike SpecialPage itself, we want the canonical forms of both
// canonical and alias title forms...
$keys = [];
// Unlike SpecialPage itself, we want the canonical forms of both
// canonical and alias title forms...
$keys = [];
- foreach ( SpecialPageFactory::getNames() as $page ) {
+ foreach ( $spFactory->getNames() as $page ) {
$keys[$contLang->caseFold( $page )] = [ 'page' => $page, 'rank' => 0 ];
}
foreach ( $contLang->getSpecialPageAliases() as $page => $aliases ) {
$keys[$contLang->caseFold( $page )] = [ 'page' => $page, 'rank' => 0 ];
}
foreach ( $contLang->getSpecialPageAliases() as $page => $aliases ) {
- if ( !in_array( $page, SpecialPageFactory::getNames() ) ) {# T22885
+ if ( !in_array( $page, $spFactory->getNames() ) ) {# T22885
*/
public function isSpecial( $name ) {
if ( $this->isSpecialPage() ) {
*/
public function isSpecial( $name ) {
if ( $this->isSpecialPage() ) {
- list( $thisName, /* $subpage */ ) = SpecialPageFactory::resolveAlias( $this->mDbkeyform );
+ list( $thisName, /* $subpage */ ) =
+ MediaWikiServices::getInstance()->getSpecialPageFactory()->
+ resolveAlias( $this->mDbkeyform );
if ( $name == $thisName ) {
return true;
}
if ( $name == $thisName ) {
return true;
}
*/
public function fixSpecialName() {
if ( $this->isSpecialPage() ) {
*/
public function fixSpecialName() {
if ( $this->isSpecialPage() ) {
- list( $canonicalName, $par ) = SpecialPageFactory::resolveAlias( $this->mDbkeyform );
+ $spFactory = MediaWikiServices::getInstance()->getSpecialPageFactory();
+ list( $canonicalName, $par ) = $spFactory->resolveAlias( $this->mDbkeyform );
- $localName = SpecialPageFactory::getLocalNameFor( $canonicalName, $par );
+ $localName = $spFactory->getLocalNameFor( $canonicalName, $par );
if ( $localName != $this->mDbkeyform ) {
return self::makeTitle( NS_SPECIAL, $localName );
}
if ( $localName != $this->mDbkeyform ) {
return self::makeTitle( NS_SPECIAL, $localName );
}
} elseif ( $this->isSpecialPage() ) {
# If it's a special page, ditch the subpage bit and check again
$name = $this->mDbkeyform;
} elseif ( $this->isSpecialPage() ) {
# If it's a special page, ditch the subpage bit and check again
$name = $this->mDbkeyform;
- list( $name, /* $subpage */ ) = SpecialPageFactory::resolveAlias( $name );
+ list( $name, /* $subpage */ ) =
+ MediaWikiServices::getInstance()->getSpecialPageFactory()->
+ resolveAlias( $name );
if ( $name ) {
$pure = SpecialPage::getTitleFor( $name )->getPrefixedText();
if ( in_array( $pure, $wgWhitelistRead, true ) ) {
if ( $name ) {
$pure = SpecialPage::getTitleFor( $name )->getPrefixedText();
if ( in_array( $pure, $wgWhitelistRead, true ) ) {
return (bool)wfFindFile( $this );
case NS_SPECIAL:
// valid special page
return (bool)wfFindFile( $this );
case NS_SPECIAL:
// valid special page
- return SpecialPageFactory::exists( $this->mDbkeyform );
+ return MediaWikiServices::getInstance()->getSpecialPageFactory()->
+ exists( $this->mDbkeyform );
case NS_MAIN:
// selflink, possibly with fragment
return $this->mDbkeyform == '';
case NS_MAIN:
// selflink, possibly with fragment
return $this->mDbkeyform == '';
+use MediaWiki\MediaWikiServices;
+
/**
* An action that just passes the request to the relevant special page
*
/**
* An action that just passes the request to the relevant special page
*
}
// map actions to (whitelisted) special pages
}
// map actions to (whitelisted) special pages
- return SpecialPageFactory::getPage( self::$actionToSpecialPageMapping[$action] );
+ return MediaWikiServices::getInstance()->getSpecialPageFactory()->
+ getPage( self::$actionToSpecialPageMapping[$action] );
$this->mAllSpecials[$ns][$dbkey] = $this->mFakePageId;
$target = null;
if ( $ns === NS_SPECIAL && $this->mResolveRedirects ) {
$this->mAllSpecials[$ns][$dbkey] = $this->mFakePageId;
$target = null;
if ( $ns === NS_SPECIAL && $this->mResolveRedirects ) {
- $special = SpecialPageFactory::getPage( $dbkey );
+ $spFactory = MediaWikiServices::getInstance()->getSpecialPageFactory();
+ $special = $spFactory->getPage( $dbkey );
if ( $special instanceof RedirectSpecialArticle ) {
// Only RedirectSpecialArticle is intended to redirect to an article, other kinds of
// RedirectSpecialPage are probably applying weird URL parameters we don't want to handle.
if ( $special instanceof RedirectSpecialArticle ) {
// Only RedirectSpecialArticle is intended to redirect to an article, other kinds of
// RedirectSpecialPage are probably applying weird URL parameters we don't want to handle.
$context->setTitle( $titleObj );
$context->setRequest( new FauxRequest );
$special->setContext( $context );
$context->setTitle( $titleObj );
$context->setRequest( new FauxRequest );
$special->setContext( $context );
- list( /* $alias */, $subpage ) = SpecialPageFactory::resolveAlias( $dbkey );
+ list( /* $alias */, $subpage ) = $spFactory->resolveAlias( $dbkey );
$target = $special->getRedirect( $subpage );
}
}
$target = $special->getRedirect( $subpage );
}
}
protected function appendSpecialPageAliases( $property ) {
$data = [];
protected function appendSpecialPageAliases( $property ) {
$data = [];
- $aliases = MediaWikiServices::getInstance()->getContentLanguage()->getSpecialPageAliases();
- foreach ( SpecialPageFactory::getNames() as $specialpage ) {
+ $services = MediaWikiServices::getInstance();
+ $aliases = $services->getContentLanguage()->getSpecialPageAliases();
+ foreach ( $services->getSpecialPageFactory()->getNames() as $specialpage ) {
if ( isset( $aliases[$specialpage] ) ) {
$arr = [ 'realname' => $specialpage, 'aliases' => $aliases[$specialpage] ];
ApiResult::setIndexedTagName( $arr['aliases'], 'alias' );
if ( isset( $aliases[$specialpage] ) ) {
$arr = [ 'realname' => $specialpage, 'aliases' => $aliases[$specialpage] ];
ApiResult::setIndexedTagName( $arr['aliases'], 'alias' );
+use MediaWiki\MediaWikiServices;
+
class OldChangesList extends ChangesList {
/**
class OldChangesList extends ChangesList {
/**
}
// Log entries (old format) or log targets, and special pages
} elseif ( $rc->mAttribs['rc_namespace'] == NS_SPECIAL ) {
}
// Log entries (old format) or log targets, and special pages
} elseif ( $rc->mAttribs['rc_namespace'] == NS_SPECIAL ) {
- list( $name, $htmlubpage ) = SpecialPageFactory::resolveAlias( $rc->mAttribs['rc_title'] );
+ list( $name, $htmlubpage ) = MediaWikiServices::getInstance()->getSpecialPageFactory()->
+ resolveAlias( $rc->mAttribs['rc_title'] );
if ( $name == 'Log' ) {
$this->insertLog( $html, $rc->getTitle(), $htmlubpage );
}
if ( $name == 'Log' ) {
$this->insertLog( $html, $rc->getTitle(), $htmlubpage );
}
return $title->getPrefixedText();
}
return $title->getPrefixedText();
}
- $linkRenderer = MediaWikiServices::getInstance()->getLinkRenderer();
+ $services = MediaWikiServices::getInstance();
+ $linkRenderer = $services->getLinkRenderer();
if ( $title->isSpecialPage() ) {
if ( $title->isSpecialPage() ) {
- list( $name, $par ) = SpecialPageFactory::resolveAlias( $title->getDBkey() );
+ list( $name, $par ) = $services->getSpecialPageFactory()->
+ resolveAlias( $title->getDBkey() );
# Use the language name for log titles, rather than Log/X
if ( $name == 'Log' ) {
# Use the language name for log titles, rather than Log/X
if ( $name == 'Log' ) {
}
public static function special( $parser, $text ) {
}
public static function special( $parser, $text ) {
- list( $page, $subpage ) = SpecialPageFactory::resolveAlias( $text );
+ list( $page, $subpage ) = MediaWikiServices::getInstance()->getSpecialPageFactory()->
+ resolveAlias( $text );
if ( $page ) {
$title = SpecialPage::getTitleFor( $page, $subpage );
return $title->getPrefixedText();
if ( $page ) {
$title = SpecialPage::getTitleFor( $page, $subpage );
return $title->getPrefixedText();
if ( $title->isSpecialPage() ) {
$type = 'ns-special';
// T25315: provide a class based on the canonical special page name without subpages
if ( $title->isSpecialPage() ) {
$type = 'ns-special';
// T25315: provide a class based on the canonical special page name without subpages
- list( $canonicalName ) = SpecialPageFactory::resolveAlias( $title->getDBkey() );
+ list( $canonicalName ) = MediaWikiServices::getInstance()->getSpecialPageFactory()->
+ resolveAlias( $title->getDBkey() );
if ( $canonicalName ) {
$type .= ' ' . Sanitizer::escapeClass( "mw-special-$canonicalName" );
} else {
if ( $canonicalName ) {
$type .= ' ' . Sanitizer::escapeClass( "mw-special-$canonicalName" );
} else {
# so it doesn't contain the original alias-with-subpage.
$origTitle = Title::newFromText( $request->getText( 'title' ) );
if ( $origTitle instanceof Title && $origTitle->isSpecialPage() ) {
# so it doesn't contain the original alias-with-subpage.
$origTitle = Title::newFromText( $request->getText( 'title' ) );
if ( $origTitle instanceof Title && $origTitle->isSpecialPage() ) {
- list( $spName, $spPar ) = SpecialPageFactory::resolveAlias( $origTitle->getText() );
+ list( $spName, $spPar ) =
+ MediaWikiServices::getInstance()->getSpecialPageFactory()->
+ resolveAlias( $origTitle->getText() );
$active = $spName == 'Contributions'
&& ( ( $spPar && $spPar == $this->username )
|| $request->getText( 'target' ) == $this->username );
$active = $spName == 'Contributions'
&& ( ( $spPar && $spPar == $this->username )
|| $request->getText( 'target' ) == $this->username );
* @return TitleValue
*/
public static function getTitleValueFor( $name, $subpage = false, $fragment = '' ) {
* @return TitleValue
*/
public static function getTitleValueFor( $name, $subpage = false, $fragment = '' ) {
- $name = SpecialPageFactory::getLocalNameFor( $name, $subpage );
+ $name = MediaWikiServices::getInstance()->getSpecialPageFactory()->
+ getLocalNameFor( $name, $subpage );
return new TitleValue( NS_SPECIAL, $name, $fragment );
}
return new TitleValue( NS_SPECIAL, $name, $fragment );
}
* @return Title|null Title object or null if the page doesn't exist
*/
public static function getSafeTitleFor( $name, $subpage = false ) {
* @return Title|null Title object or null if the page doesn't exist
*/
public static function getSafeTitleFor( $name, $subpage = false ) {
- $name = SpecialPageFactory::getLocalNameFor( $name, $subpage );
+ $name = MediaWikiServices::getInstance()->getSpecialPageFactory()->
+ getLocalNameFor( $name, $subpage );
if ( $name ) {
return Title::makeTitleSafe( NS_SPECIAL, $name );
} else {
if ( $name ) {
return Title::makeTitleSafe( NS_SPECIAL, $name );
} else {
*/
function getLocalName() {
if ( !isset( $this->mLocalName ) ) {
*/
function getLocalName() {
if ( !isset( $this->mLocalName ) ) {
- $this->mLocalName = SpecialPageFactory::getLocalNameFor( $this->mName );
+ $this->mLocalName = MediaWikiServices::getInstance()->getSpecialPageFactory()->
+ getLocalNameFor( $this->mName );
}
return $this->mLocalName;
}
return $this->mLocalName;
* @ingroup SpecialPage
*/
* @ingroup SpecialPage
*/
+use MediaWiki\MediaWikiServices;
+
/**
* A special page that lists special pages
*
/**
* A special page that lists special pages
*
}
private function getPageGroups() {
}
private function getPageGroups() {
- $pages = SpecialPageFactory::getUsablePages( $this->getUser() );
+ $pages = MediaWikiServices::getInstance()->getSpecialPageFactory()->
+ getUsablePages( $this->getUser() );
if ( !count( $pages ) ) {
# Yeah, that was pointless. Thanks for coming.
if ( !count( $pages ) ) {
# Yeah, that was pointless. Thanks for coming.
- $specialObj = SpecialPageFactory::getPage( $special );
+ $specialObj = MediaWikiServices::getInstance()->getSpecialPageFactory()->
+ getPage( $special );
if ( !$specialObj ) {
$this->output( "No such special page: $special\n" );
exit;
if ( !$specialObj ) {
$this->output( "No such special page: $special\n" );
exit;
+use MediaWiki\MediaWikiServices;
+
/**
* @group API
* @group medium
/**
* @group API
* @group medium
public function testSpecialPageAliases() {
$this->assertCount(
public function testSpecialPageAliases() {
$this->assertCount(
- count( SpecialPageFactory::getNames() ),
+ count( MediaWikiServices::getInstance()->getSpecialPageFactory()->getNames() ),
$this->doQuery( 'specialpagealiases' )
);
}
$this->doQuery( 'specialpagealiases' )
);
}
* @author Antoine Musso
*/
* @author Antoine Musso
*/
+use MediaWiki\MediaWikiServices;
+
/**
* @group Database
* @covers QueryPage<extended>
/**
* @group Database
* @covers QueryPage<extended>
$class = $page[0];
$name = $page[1];
if ( !in_array( $class, $this->manualTest ) ) {
$class = $page[0];
$name = $page[1];
if ( !in_array( $class, $this->manualTest ) ) {
- $this->queryPages[$class] = SpecialPageFactory::getPage( $name );
+ $this->queryPages[$class] =
+ MediaWikiServices::getInstance()->getSpecialPageFactory()->getPage( $name );
$ctx = new RequestContext;
$sp = Title::newFromText( 'Special:Search/foo_bar' );
$ctx = new RequestContext;
$sp = Title::newFromText( 'Special:Search/foo_bar' );
- SpecialPageFactory::executePath( $sp, $ctx );
+ MediaWikiServices::getInstance()->getSpecialPageFactory()->executePath( $sp, $ctx );
$url = $ctx->getOutput()->getRedirect();
// some older versions of hhvm have a bug that doesn't parse relative
// urls with a port, so help it out a little bit.
$url = $ctx->getOutput()->getRedirect();
// some older versions of hhvm have a bug that doesn't parse relative
// urls with a port, so help it out a little bit.
+use MediaWiki\MediaWikiServices;
+
/**
* Test that runs against all registered special pages to make sure that regular
* execution of the special page does not cause a fatal error.
/**
* Test that runs against all registered special pages to make sure that regular
* execution of the special page does not cause a fatal error.
public function provideSpecialPages() {
$specialPages = [];
public function provideSpecialPages() {
$specialPages = [];
- foreach ( SpecialPageFactory::getNames() as $name ) {
- $specialPages[$name] = [ SpecialPageFactory::getPage( $name ) ];
+ $spf = MediaWikiServices::getInstance()->getSpecialPageFactory();
+ foreach ( $spf->getNames() as $name ) {
+ $specialPages[$name] = [ $spf->getPage( $name ) ];
}
return $specialPages;
}
}
return $specialPages;
}